package threadDemo1.getState;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 38917
 * Date: 2025-02-27
 * Time: 23:35
 */
public class ThreadDemo {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            for (int i = 1; i <= 3; i++) {
                System.out.println("Hello Thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        },"Thread_14");
        //NEW,线程实例化之后->启动之前
        System.out.println(thread.getState());
        thread.start();
        //RUNNABLE(可执行),线程启动后
        System.out.println(thread.getState());
        //线程休眠100毫秒
        Thread.sleep(100);
        //TIMED_WAITING
        System.out.println(thread.getState());

        thread.join();
        //TERMINATED
        System.out.println(thread.getState());
    }
}